<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>simSetThreadIsFree</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../../index.html" TARGET="_top"><img src="../images/homeImg.png"></a></p>

<h1><a href="../apiOverview.htm">Regular API</a> function</h1>
<h3 class=subsectionBar><a name="simSetThreadIsFree" id="simSetThreadIsFree"></a>simSetThreadIsFree / sim.setThreadIsFree </h3>
<table class=apiTable>
<tr class=apiTableTr> 
<td class=apiTableLeftDescr>
Description 
</td> 
<td class=apiTableRightDescr>Threads created by CoppeliaSim are never running concurrently, they rather behave like coroutines. This allows achieving similar results as with &quot;pure threads&quot;, except when an external command is blocking (e.g. commands not directly supported by CoppeliaSim). Those can be lengthly image processing routines, or socket communication routines for example. When such external blocking commands are called, CoppeliaSim appears frozen until the external commands return. To avoid such a situation, you can declare a non-blocking section with the <a href="simSetThreadIsFree.htm">sim.setThreadIsFree</a> command: <a href="simSetThreadIsFree.htm">sim.setThreadIsFree</a>(true) starts a non-blocking section, and <a href="simSetThreadIsFree.htm">sim.setThreadIsFree</a>(false) closes it. Try to avoid using CoppeliaSim commands when in a non-blocking section (bad synchronization), and never forget to close a non-blocking section, otherwise CoppeliaSim will hang indefinitely. Use <a href="simSetThreadIsFree.htm">sim.setThreadIsFree</a> with extra care when calling it from C. A thread running in a non-blocking section cannot be paused nor stopped. This command has no effect when called from the main thread or a non-threaded script.<br></td>
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCSyn>
C synopsis
</td> 
<td class=apiTableRightCSyn>simInt simSetThreadIsFree(simBool freeMode)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCParam>C parameters</td> 
<td class=apiTableRightCParam>
<div><strong>freeMode</strong>: specify 1 to start a non-blocking section. Specify 0 to end a non-blocking section<br>
</div>
<div></div></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCRet>
C return value
</td> 
<td class=apiTableRightCRet>
<div>1<br>
</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLSyn>
Lua synopsis
</td> 
<td class=apiTableRightLSyn>sim.setThreadIsFree(Boolean freeMode)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLParam>Lua parameters</td> 
<td class=apiTableRightLParam>
<div><strong>freeMode</strong>: specify true to start a non-blocking section. Specify false to end a non-blocking section</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLRet>
Lua return values
</td> 
<td class=apiTableRightLRet>
<div>none</div></td> 
</tr> 
</table> 

<br>
<p><a href="../apiFunctions.htm">All regular API functions on one page</a></p>
<br>
<br>
</td>
</tr>
</table>
</div>
</body>
</html>
